//
//  CalculatorButtonPad.swift
//  Calculator
//
//  Created by c on 2021/1/12.
//  Copyright © 2021 CDFMLR. All rights reserved.
//

import SwiftUI

/// CalculatorButtonPad: 计算器按键盘面
struct CalculatorButtonPad: View {
//    @Binding var brain: CalculatorBrain
//    var model: CalculatorModel
    
    let pad: [[CalculatorButtonItem]] = [
        [.command(.clear), .command(.flip), .command(.percent), .op(.divide)],
        [.digit(7), .digit(8), .digit(9), .op(.multiply)],
        [.digit(4), .digit(5), .digit(6), .op(.minus)],
        [.digit(1), .digit(2), .digit(3), .op(.plus)],
        [.digit(0), .dot, .op(.equal)],
    ]

    var body: some View {
        VStack(spacing: 8) {
            ForEach(pad, id: \.self) { row in
//                CalculatorButtonRow(row: row, model: self.model)
                CalculatorButtonRow(row: row)
            }
        }
    }
}

struct CalculatorButtonPad_Previews: PreviewProvider {
    static var previews: some View {
//        CalculatorButtonPad(model: CalculatorModel())
        CalculatorButtonPad()
    }
}
